home *** CD-ROM | disk | FTP | other *** search
/ Enter 2010 January / ENTER_2010_01.iso / Programy / Gry / Base_Invaders_ / BaseInvadersSetup1.3.exe / {app} / Scripts / IntroImagePopup.lua < prev    next >
Encoding:
Text File  |  2007-01-25  |  2.8 KB  |  111 lines

  1.  
  2. -----------------------------------------
  3. --            INTRO IMAGE BOX
  4. -----------------------------------------
  5.  
  6. -- DON'T Set these directly:
  7. IntroZoomSize = true
  8. IntroImageColor = Color(1,1,1,1)
  9. IntroImageSize = Vector3(0.75, 0.75, 0 )
  10.  
  11. function FadeOut( fadeTime )
  12.     IntroZoomSize = false
  13.     SetImagePopupTiming( fadeTime, 10, 0.05 );
  14.     IntroImageSize = Vector3(2, 2, 0 )
  15.     IntroImagePopup( "Textures/Black.bmp" )
  16. end
  17.  
  18. function FadeIn( fadeTime )
  19.     IntroZoomSize = false
  20.     SetImagePopupTiming( 0, 0.05, fadeTime );
  21.     IntroImageSize = Vector3(2, 2, 0 )
  22.     IntroImagePopup( "Textures/Black.bmp" )
  23. end
  24.  
  25. function SetImagePopupTiming( inTime, waitTime, outTime )
  26.     ImageFadeInDur    = inTime;
  27.     ImageWaitDur    = waitTime;
  28.     ImageFadeOutDur    = outTime;
  29.     TotalImageDur = ImageFadeInDur + ImageWaitDur + ImageFadeOutDur
  30. end
  31.  
  32. SetImagePopupTiming( 0.5, 0.75, 0.75 );
  33.  
  34. function KillImagePopup()
  35.     if( IntroImage ~= nil and IntroImage.IsValid() ) then
  36.         IntroImage.Destroy();
  37.     end
  38. end
  39.  
  40. function IntroImagePopup( imageName )
  41.     if( IntroImage == nil or not(IntroImage.IsValid()) ) then
  42.         G.Create( "MenuData/IntroImageCog.xml" );
  43.     end
  44.     
  45.     IntroImage.SetGuiPosition( "IntroImageBox", Vector3(0,0,0) );
  46.     IntroImage.Message( "IntroImageBox", "setimage", imageName );
  47.     
  48.     IntroImageColor[3] = 0;
  49.     if( ImageFadeInDur == 0 ) then
  50.         IntroImageColor[3] = 1
  51.     end
  52.     
  53.     IntroImage.SetColor( "IntroImageBox", IntroImageColor );
  54.     
  55.     if( IntroZoomSize ) then
  56.         IntroImage.SetGuiSize("IntroImageBox", Vector3(0,0,0) );
  57.     else
  58.         IntroImage.SetGuiSize("IntroImageBox", IntroImageSize );
  59.     end
  60.     
  61.     ImageFadeTime = TotalImageDur
  62. end
  63.  
  64. function ColorImagePopup( imageName, color )
  65.  
  66.     IntroImageColor = color
  67.     IntroImagePopup( imageName )
  68. end
  69.  
  70.  
  71. function ImageFadeFunc()
  72.     -- Fade image over time
  73.     if( IntroImage ~= nil and IntroImage.IsValid() ) then
  74.         ImageFadeTime = ImageFadeTime - GameTimeDiff;
  75.  
  76.         -- First Fade in:
  77.         if( ImageFadeTime > ImageWaitDur + ImageFadeOutDur ) then
  78.             IntroImageColor[3] = (TotalImageDur - ImageFadeTime) / ImageFadeInDur;
  79.         else 
  80.             if( ImageFadeTime > ImageFadeOutDur ) then
  81.                 IntroImageColor[3] = 1;
  82.             else
  83.                 IntroImageColor[3] = ImageFadeTime / ImageFadeOutDur;
  84.             end
  85.         end
  86.  
  87.         -- Pop the text box too:
  88.         local curSize = Vector3(0,0,0)
  89.  
  90.         if( IntroZoomSize ) then
  91.             curSize[0] = IntroImageSize[0] * IntroImageColor[3]
  92.             curSize[1] = IntroImageSize[1] * IntroImageColor[3]
  93.             curSize[2] = IntroImageSize[2] * IntroImageColor[3]
  94.         else
  95.             curSize[0] = IntroImageSize[0]
  96.             curSize[1] = IntroImageSize[1]
  97.             curSize[2] = IntroImageSize[2]
  98.         end
  99.         
  100.         IntroImage.SetGuiSize( "IntroImageBox", curSize );
  101.         IntroImage.SetColor( "IntroImageBox", IntroImageColor );
  102.  
  103.         if( ImageFadeTime < 0 ) then
  104.             KillImagePopup()
  105.         end
  106.     end
  107. end
  108.  
  109. -- Always update Function:
  110. GMain[ "ImageFadeFunc" ] = ImageFadeFunc;
  111.